package com.lazily.custom_exceptions;


/**
 * @Author: GZQ
 * @date: 2025/2/24 19:47
 * @description: 自定义异常练习
 */

public class ThrowException {

	// 程序入口
	public static void main(String[] args) {
		try {
			ReturnExceptionDemo.methodA();
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		ReturnExceptionDemo.methodB();
	}
}


class ReturnExceptionDemo {
	static void methodA() {
		try {
			System.out.println("进入方法A");
			throw new RuntimeException("制造异常");
		} finally {
			System.out.println("用A方法的finally");
		}
	}

	static void methodB() {
		try {
			System.out.println("进入方法B");
		} finally {
			System.out.println("调用B方法的finally");
		}
	}
}